<?php
namespace app\pos_v1\validate;

use think\Validate;

/** 发起支付请求参数验证 */
class SellPosPAY_Pay extends Validate
{
    protected $rule = [
        'dbid' => 'require|string', //POS销售单号
        "sign" => "require|string",
        "payway" => "require|in:9,8",//支付方式_9现金8聚合支付
        "total_amount" => "require|>:0",//交易金额
        "dynamic_id" => "string",//支付码（支付宝或微信条码号-线上支付时必填）
        "operator" => "require|string",//门店操作员
        "remark" => "string",//备注
        "pay_currency" => "string|in:A1,RMB,HKD,USD",//支付币种-云支付时无效
        // 'client_sn' => 'length:2,99', //
        // "table_detail" =>  "require|array|length:1,999", //
        // 'user_type' => 'require|in:user,agent,admin',
    ];
    protected $message = [
        'dbid' => 'POS销售单号[dbid]',
        "sign" => "改单签名串[sign]",
        "payway.require" => "支付方式必填[payway]",//支付方式_9现金8聚合支付
        "payway" => "支付方式只能是9、8[payway]",//支付方式_9现金8聚合支付
        "total_amount.require" => "交易金额必填[total_amount]",//交易金额
        // "total_amount.number" => "交易金额只能是数字[total_amount]",//交易金额
        // "total_amount" => "交易金额[total_amount]",//交易金额
        // "total_amount.>=" => "交易金额大于等于0.01[total_amount]",//交易金额
        "dynamic_id" => "支付码[dynamic_id]",//支付码（支付宝或微信条码号-线上支付时必填）
        "operator" => "门店操作员[operator]",//门店操作员
        "remark" => "支付备注[remark]",//备注
        "pay_currency" => "支付币种[pay_currency]",//支付币种-云支付时无效
        // 'name.max'     => '名称最多不能超过25个字符',
        // 'user_type.require' => '帐号类型必须', //帐号类型admin总部agent代理user一般用户
        // 'user_type.in' => '帐号类型仅限:user,agent,admin', //帐号类型admin总部agent代理user一般用户
    ];
    // 自定义验证方法-帐号类型
    protected function userType($value, $rule, $requestdb)
    {
        // dump($value);
        // dump($rule);
        // dump($requestdb);
    }
}
